package com.aauedu.springboot.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 1、通过继承HttpServlet来开发原生的Servlet
 * 2、@WebServlet标识将Servlet_对象注入到容器中
 * 3、urlPatterns = {"/servlet01", "/servlet02"},对Servlet配置了url-pattern
 * 4、注意注入的原生的Servlet_不会被SpringBoot拦截器拦截
 * 5、对于开发的原生的Servlet，需要使用@ServletComponentScan指定要扫描的原生Servlet子包，才会注入到Spring容器
 */
//@WebServlet(urlPatterns = {"/servlet01", "/servlet02"})
public class Servlet_ extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.getWriter().write( "hello,Servlet_!");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
